package com.mt.roll.wms.controller;


import com.mt.roll.core.constants.CommonConstant;
import com.mt.roll.core.params.EnabledParam;
import com.mt.roll.core.params.IdListParam;
import com.mt.roll.core.params.IdParam;
import com.mt.roll.core.validator.groups.AddGroup;
import com.mt.roll.core.validator.groups.PageGroup;
import com.mt.roll.core.validator.groups.UpdateGroup;
import com.mt.roll.core.vo.IdListVo;
import com.mt.roll.core.vo.IdVo;
import com.mt.roll.core.vo.PageVo;
import com.mt.roll.core.vo.R;
import com.mt.roll.wms.params.ScrapTypeInformationParam;
import com.mt.roll.wms.params.ScrapTypeInformationQueryParam;
import com.mt.roll.wms.service.ScrapTypeInformationService;
import com.mt.roll.wms.vo.ScrapTypeInformationVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.groups.Default;
import java.util.List;

/**
 * @Author weihongyang
 * @Date 2021/3/10 8:59 上午
 * @Version 1.0
 */
@RestController
@RequestMapping(CommonConstant.API_MODULE_WMS + "scrap-type-information")
@Slf4j
@Api(value = "平台报废类型信息管理", tags = "平台报废类型信息管理接口", hidden = false)
public class ScrapSubReasonTypeController {
    @Autowired
    private ScrapTypeInformationService scrapTypeInformationService;

    @PostMapping(value = "get")
    @ApiOperation(value = "获取报废类型信息")
    private R<ScrapTypeInformationVo> get(@Validated @RequestBody IdParam idParam) {
        return scrapTypeInformationService.get(idParam);
    }

    @PostMapping(value = "list")
    @ApiOperation(value = "获取xx列表")
    private R<List<ScrapTypeInformationVo>> list(@Validated({Default.class}) @RequestBody ScrapTypeInformationQueryParam scrapTypeInformationQueryParam) {
        return scrapTypeInformationService.list(scrapTypeInformationQueryParam);
    }

    @PostMapping(value = "page")
    @ApiOperation(value = "获取分页报废类型信息")
    private R<PageVo<ScrapTypeInformationVo>> page(@Validated({PageGroup.class, Default.class}) @RequestBody ScrapTypeInformationQueryParam scrapTypeInformationQueryParam) {
        return scrapTypeInformationService.page(scrapTypeInformationQueryParam);
    }

    @PostMapping(value = "tree")
    @ApiOperation(value = "获取xx树列表")
    private R<List<ScrapTypeInformationVo>> tree(@Validated({Default.class}) @RequestBody ScrapTypeInformationQueryParam scrapTypeInformationQueryParam) {
        return scrapTypeInformationService.tree(scrapTypeInformationQueryParam);
    }

    @PostMapping(value = "add")
    @ApiOperation(value = "新增")
    private R<IdVo> add(@Validated({AddGroup.class, Default.class}) @RequestBody ScrapTypeInformationParam scrapTypeInformationParam) {
        return scrapTypeInformationService.add(scrapTypeInformationParam);
    }

    @PostMapping(value = "update")
    @ApiOperation(value = "更新")
    private R<IdVo> update(@Validated({UpdateGroup.class, Default.class}) @RequestBody ScrapTypeInformationParam scrapTypeInformationParam) {
        return scrapTypeInformationService.update(scrapTypeInformationParam);
    }

    @PostMapping(value = "enabled")
    @ApiOperation(value = "启停xx")
    private R<IdVo> enabled(@Validated @RequestBody EnabledParam enabledParam) {
        return scrapTypeInformationService.enabled(enabledParam);
    }

    @PostMapping(value = "delete")
    @ApiOperation(value = "删除报废类型信息")
    private R<IdVo> delete(@Validated @RequestBody IdParam idParam) {
        return scrapTypeInformationService.delete(idParam);
    }

    @PostMapping(value = "batchDelete")
    @ApiOperation(value = "批量删除xx")
    private R<IdListVo> delete(@Validated @RequestBody IdListParam idListParam) {
        return scrapTypeInformationService.delete(idListParam);
    }

    @PostMapping(value = "get-code")
    @ApiOperation(value = "获取报废类型信息code")
    private R<String> getCode() {
        return scrapTypeInformationService.getCode();
    }
}
